define(function() {
	return function($compile, $scope) {
		require(
				[ "AppPathDir/relation/relationInfos/support",
						"AppPathDir/relation/relationInfos/add",
						"PDUtilDir/util", "PDUtilDir/tool",
						"PDUtilDir/slidebar", "PDUtilDir/inputSelect", "Date",
						"DateCN", "css!DateCss",
						"css!AppPathDir/relation/relationInfos/views/css/css" ],
				function(Support, AddSupport, Util, Tool,
						Slidebar, inputSelect) {
					/* 查询 start */
					$scope.search = {};
					$scope.cache = {};
					
					$.ajax({
						url : getServer() + "/flea/dict/initTree.htmls",
						data : {
							'dictCode' : 'D_SERVICE_ORG'
						},
						success : function(data) {
							$scope.cache.serviceTypes = data;
							init_serviceTypes();
							$scope.grid = Support.init($scope.cache, $scope.addSupport/*, $scope.delSupport*/, $scope.searchSupport);
						}
					});
					$.ajax({
						url : getServer() + "/flea/hclv/getProvinces.htmls",
						success : function(data) {
							$scope.cache.provinces = data.data;
							init_queryProvince();
						}
					});
					$scope.getCity = function(pcode) {
						$.ajax({
							url : getServer() + "/flea/hclv/getCity.htmls",
							data : {
								'pcode' : pcode
							},
							success : function(data) {
								$scope.cache.city = data.data;
								init_queryCity();
							}
						});
					};
					var init_serviceTypes = function() {
						// 初始化下拉框
						inputSelect.dropCache();
						inputSelect({
							id : "serviceType",
							key : {
								id : "dictCode",
								name : "dictName",
								data : "data",
							},
							data : $scope.cache.serviceTypes,
							simpleData : true,
							searchAble : false,
							callback : function(id) {
								$scope.search.serviceType = id[0];
							}
						});
					},init_queryProvince = function() {
						// 初始化下拉框
						inputSelect.dropCache();
						inputSelect({
							id : "queryProvince",
							key : {
								id : "dictCode",
								name : "dictName",
								data : "data",
							},
							data : $scope.cache.provinces,
							simpleData : true,
							// 启用文本搜索
							// initData:[initProvice],
							searchAble : false,
							callback : function(id) {
								var id = id[0];
								$scope.search.queryProvince = id;
								$scope.getCity(id);
							}
						});
					}, init_queryCity = function() {
						// 初始化下拉框
						inputSelect.dropCache();
						inputSelect({
							id : "queryCity",
							key : {
								id : "dictCode",
								name : "dictName",
								data : "data",
							},
							data : $scope.cache.city,
							simpleData : true,
							// 启用文本搜索
							// initData:[initProvice],
							searchAble : false,
							callback : function(id) {
								var id = id[0];
								$scope.search.queryCity = id;
							}
						});
					};
					$scope.searchSupport = {
						run : function() {
							$scope.grid.reload({
								queryParam : $scope.search
							})
						}
					};
					$scope.addSupport = AddSupport($scope, $compile);
				})
	}
});